Skip to content

[FIX] base_exception: reload the view after the exception dialog - #3734

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
adhoc-dev:18.0-t-75452-lef
Oct 7, 2026
Merged

OCA-git-bot merged 1 commit into
OCA:18.0from
adhoc-dev:18.0-t-75452-lef

Conversation

@lef-adhoc

Copy link
Copy Markdown
Contributor

The problem

Confirm a sales order that hits an exception rule. The dialog shows up, you tick Ignore Exceptions and confirm.

The order is confirmed — but the view behind the dialog still shows it as a quotation, with the red exception banner and the Confirm button. You have to reload the page by hand to see the real state, and until you do you can hit Confirm again on an order that is already confirmed.

How to reproduce

On 18.0 with sale_exception installed:

  1. Add an exception.rule on sale.order, by_py_code, that matches one customer.
  2. Create an order for that customer and confirm it → the exception dialog shows up.
  3. Tick Ignore Exceptions and confirm.
  4. The view still shows Quotation, but the order is already sale in the database. Reload the page and the real state appears.

Why

The dialog can change the record: ticking "Ignore Exceptions" calls action_confirm on it. But the wizard returns ir.actions.act_window_close, which closes the dialog and nothing else, so the view keeps the state it had before.

The fix

Reload once the dialog is closed, using the onClose option of doAction:

await env.services.action.doAction(popupAction, {
    onClose: () =>
        env.services.action.doAction({
            type: "ir.actions.client",
            tag: "soft_reload",
        }),
});

It goes here rather than in the wizard's return value for two reasons: action_confirm on the wizard is inherited by several modules, and this way the fix covers every model using the mechanism, not just sales.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @hparfr, @sebastienbeau,
some modules you are maintaining are being modified, check this out!

@lef-adhoc lef-adhoc changed the title [WIP] [FIX] base_exception: reload the view after the exception dialog [FIX] base_exception: reload the view after the exception dialog Sep 18, 2026
@lef-adhoc

lef-adhoc commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@grindtildeath could you take a look? This follows up on #3590 and OCA/sale-workflow#4255, so you are the one with the context.

The dialog can now confirm the record, and closing it leaves the view showing the previous state. Reloading on close seemed like the smallest fix

The dialog can confirm the record (ticking "Ignore Exceptions" calls
action_confirm on it), but closing it only closes the dialog: the view
underneath keeps showing the record as it was before, so the user sees a
quotation that is already a sales order.

Reload once the dialog closes.

@UsmanGhias UsmanGhias left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean patch for OCA/server-tools.

Observations:

  • Template and component structure preserves standard inheritance patterns.

Ready for testing on standard environments.

Best,
Usman

@grindtildeath grindtildeath left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thank you 👍

@nicolascol nicolascol left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

await env.services.action.doAction(popupAction);
await env.services.action.doAction(popupAction, {
onClose: () =>
env.services.action.doAction({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering, shouldn't we instead do the soft reload before the popup is opened?

AFAIU we could modify the error handler below instead and do this at line 25:

        const excData = JSON.parse(originalError.data.message);
        env.services.action.doAction({
            type: "ir.actions.client",
            tag: "soft_reload",
        });
        if (excData.target_model === controller.props.resModel) {
            env.services.action.doAction({
                type: "ir.actions.client",
                tag: "popup_exception",
            });
        } 
        return true;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grindtildeath the soft reload before the popup is already there — action.restore(controller.jsId) a couple of lines above, that's what makes the exception show up on the form.

What this PR fixes happens after: the dialog can confirm the record (Ignore Exceptions + Confirm runs action_ignore_exceptions() + action_confirm()), so when it closes the order is already state=sale while the form still shows the quotation and the exception banner. A reload before the popup can't reflect a change that hasn't happened yet.

I tried both on 18.0 with a non-blocking rule: with the reload moved to the handler, the form stays on "Quotation" with the banner while the record is confirmed in DB — same as without the fix. With onClose it reloads as expected.

@lef-adhoc

Copy link
Copy Markdown
Contributor Author

@simahawk Hi, can you check this?

@simahawk

simahawk commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 18.0-ocabot-merge-pr-3734-by-simahawk-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit a495d26 into OCA:18.0 Oct 7, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at e4712e6. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants